package com.zc.web.controller.timedown;

import com.zc.common.core.domain.R;
import com.zc.web.service.IStatisticService;
import com.zc.web.vo.StatisticsVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * ClassName:StatisticsController
 * Description:
 * DateTime: 2025/10/22 13:38
 * Author: zc
 * Version: 1.0
 */
@RestController
@RequestMapping("/wx/statistics")
public class StatisticsController {


    @Autowired
    private IStatisticService statisticService;

    /**
     * 获取各项统计数据
     */
    @GetMapping("/overview")
    @ApiOperation("获取系统概览统计")
    public R<StatisticsVO> getSystemOverview() {
        StatisticsVO statistics = statisticService.getStatisticsOverview();
        return  R.ok(statistics);
    }

    /**
     * 获取用户年龄分布统计
     */
    @GetMapping("/ages")
    public R<Map<String, Integer>> getUserAgeStatistics() {
        Map<String, Integer> ageStatistics = statisticService.getUserAgeStatistics();
        return R.ok(ageStatistics);
    }

    @GetMapping("/timeRecord")
    public R<Map<String, Integer>>getTimeBookCategoryStatistics() {
        Map<String, Integer> timeBookCategoryStatistics = statisticService.getTimeBookCategoryStatistics();
        return R.ok(timeBookCategoryStatistics);
        }

    }
